uniform vec3 bounds1;
uniform vec3 bounds2;
uniform float isPortrait;
uniform float texelWidth;
uniform float texelHeight;


void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 textureCoordinate = fragCoord.xy / iResolution.xy;
    
    vec2 uv = isPortrait > 0.5 ? textureCoordinate.xy : vec2(textureCoordinate.y, textureCoordinate.x);
    float texelSize = isPortrait > 0.5 ? texelWidth : texelHeight;
    if(uv.y > bounds1.x && uv.y < bounds2.y) {
        if (uv.y < bounds1.y) {
            uv.x += texelSize * (cos(abs(uv.y - bounds1.z) * 314.0) + 1.0) * 0.5;
        } else if (uv.y > bounds2.x) {
            uv.x += texelSize * (cos(abs(uv.y - bounds2.z) * 314.0) + 1.0) * 0.5;
        }
    }
    fragColor = texture(iChannel0,  isPortrait > 0.5 ? uv : vec2(uv.y, uv.x) );
    
   // fragColor = vec4(1.0, 0.0, 0.0, 1.0);
}


